package io.chenglicun.modules.bus.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.chenglicun.common.service.impl.CrudServiceImpl;
import io.chenglicun.common.constant.Constant;
import io.chenglicun.modules.bus.dao.BusNoticeDao;
import io.chenglicun.modules.bus.dto.BusNoticeDTO;
import io.chenglicun.modules.bus.entity.BusNoticeEntity;
import io.chenglicun.modules.bus.service.BusNoticeService;
import io.chenglicun.modules.security.user.SecurityUser;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 业务_公告
 *
 * @author HB 137664951@qq.com
 * @since 1.0 2023-08-30
 */
@Service
public class BusNoticeServiceImpl extends CrudServiceImpl<BusNoticeDao, BusNoticeEntity, BusNoticeDTO> implements BusNoticeService {

    @Override
    public QueryWrapper<BusNoticeEntity> getWrapper(Map<String, Object> params){
        QueryWrapper<BusNoticeEntity> wrapper = new QueryWrapper<>();

        String type = (String)params.get("type");
        wrapper.eq(StringUtils.isNotBlank(type), "type", type);
        String title = (String)params.get("title");
        wrapper.like(StringUtils.isNotBlank(title), "title", title);
        String textType = (String)params.get("textType");
        wrapper.eq(StringUtils.isNotBlank(textType), "text_type", textType);
        String isPublish = (String)params.get("isPublish");
        wrapper.eq(StringUtils.isNotBlank(isPublish), "is_publish", isPublish);
        String isTopped = (String)params.get("isTopped");
        wrapper.eq(StringUtils.isNotBlank(isTopped), "is_topped", isTopped);
        String tabType = (String)params.get("tab_type");
        wrapper.eq(StringUtils.isNotBlank(tabType), "tab_type", tabType);
        wrapper.orderByDesc("create_date","sort");
        return wrapper;
    }


    @Override
    public Integer getMaxSort() {
        return baseDao.getMaxSort()+1;
    }
}
